// 배열
//작성일:14.10.30
//작성자: 주대규
//나열문:array.html,array.css,array.js
function arrayTest1(){
	
	array = new Array();

	cnt =0;
	document.getElementById("btnAdd").onclick =addFunc;
	document.getElementById("btnView").onclick =viewFunc;
	document.getElementById("btnSort").onclick =sortFunc;
	document.getElementById("btnNumSort").onclick =numSortFunc;

}
function addFunc(){
	var f = document.frm;
	var d = f.data.value;
	array[cnt] = d;
	cnt++;
	
}
function viewFunc(){
		var f = document.frm;
		var rst = document.getElementById("restltDiv");
//	alert("나와");
		f.result.value = array.join('\n');
		rst.innerHTML = array.join('<br/>');
}
function sortFunc(){
	var f = document.frm;
	var rst = document.getElementById("restltDiv");
	
	array.sort();
	
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');
}
function numSortFunc(){
	var f = document.frm;
	var rst = document.getElementById("restltDiv");
	
	array.sort(numSort);
//	alert("dsaf")
	f.result.value = array.join('\n');
	rst.innerHTML = array.join('<br/>');	
}
function numSort(x,y){
	return Number(x)-Number(y);//오름차순
	//return Number(y)-Number(x);
	
}